home *** CD-ROM | disk | FTP | other *** search
- Path: ees1a0.engr.ccny.cuny.edu!rpi!not-for-mail
- From: overhaul@nmia.com (Daniel N. Sands)
- Newsgroups: gnu.g++.help,comp.lang.c++.moderated,comp.lang.c++
- Subject: Re: Multiple copies of Virtual Table
- Followup-To: gnu.g++.help,comp.lang.c++.moderated,comp.lang.c++
- Date: 16 Feb 1996 11:29:32 -0000
- Organization: New Mexico Internet Access
- Sender: cppmods@netlab.cs.rpi.edu
- Approved: devitto@ferndown.ate.slb.com
- Message-ID: <4g1pqs$pvl@netlab.cs.rpi.edu>
- References: <4fvj0l$ii7@netlab.cs.rpi.edu>
- NNTP-Posting-Host: netlab.cs.rpi.edu
- X-Original-Date: 16 Feb 1996 06:41:50 GMT
-
- Mike ODowd wrote:
- #-> I have noticed that the size of my code has been growing
- #-> at an alarming rate recently. After some investigation, I
- #-> discovered that it is due to multiple copies of virtual tables.
- #->
- #-> It seems that each object file that accesses a class, ends up
- #-> with a copy of that class' virtual table. I one case, I counted
- #-> 91 object files that contain a copy of the same virtual table.
- #->
- #-> The virtual tables are taking up something like 25% of my code.
- #->
- #-> Please tell me that there is a way around this, that my code size
- #-> is not going to expand exponentially.
- #->
- #-> I am using gcc v2.6.0.
-
- I may know what's up: If you define instances of your class in the
- header file:
-
- <foo.h>
-
- Myclass Foo1;
-
- Every file that includes foo.h will make a copy of Foo1, and a virtual
- table to match. Make sure all data declared in the header files is
- "extern". Then define the actual instance in one of your modules.
-
- { This isn't a clear example - anyone care to summise the problems of
- inlines/templates and vtbl emmision ?? -mod}
-
- [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
- [ Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm ]
- [ Moderation policy: http://www.connobj.com/cpp/guide.htm ]
- [ Comments? mailto:c++-request@netlab.cs.rpi.edu ]
-